<!--# layout("/common/layout.html",{"jsBase":"/js/orgLecture/orgLecture/"}){ -->
 <style type="text/css">
    .uploader-list {
        margin-left: -15px;
    }

    .uploader-list .info {
        position: relative;
        margin-top: -25px;
        background-color: black;
        color: white;
        filter: alpha(Opacity=80);
        -moz-opacity: 0.5;
        opacity: 0.5;
        width: 100px;
        height: 25px;
        text-align: center;
        display: none;
    }

    .uploader-list .handle {
        position: relative;
        background-color: black;
        color: white;
        filter: alpha(Opacity=80);
        -moz-opacity: 0.5;
        opacity: 0.5;
        width: 100px;
        text-align: right;
        height: 18px;
        margin-bottom: -18px;
        display: none;
    }

    .uploader-list .handle span {
        margin-right: 10px;
    }

    .uploader-list .handle span:hover {
        cursor: pointer;
    }

    .uploader-list .file-iteme {
        margin: 12px 0 0 15px;
        padding: 1px;
        float: left;
    }
</style>
<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="lectureId" id="lectureId">
<br/>

<div class="layui-row">
    <div class="layui-form-item">

        <!--#if(accessType==6){ -->
        <div class="layui-inline">
            <label class="layui-form-label">讲座省份</label>
            <div class="layui-input-inline">
                <layui:simpleDataSelect name="provinceId" value="" data="${provinceList}"
                                        attrId="provId" attrName="provName" layFilter="colFilter" id="provinceId"  laySearch="true"/>
            </div>
        </div>
        <!--#}-->

        <div class="layui-inline">
            <label class="layui-form-label">讲座主题</label>
            <div class="layui-input-inline">
                <input type="text" name="lectureTitle" id="lectureTitle" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required">
            </div>
        </div>
    </div>
</div>

<div class="layui-row">
    <div class="layui-form-item">
        <div class="layui-inline">
        <label class="layui-form-label">讲座老师</label>
            <div class="layui-input-inline">
                <layui:simpleDataSelect name="customerId" value="" data="${customerInfoList}"
                                        attrId="customerId" attrName="customerName" layFilter="customerFilter" id="customer_author" laySearch="true" />
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">讲座时间</label>
            <div class="layui-input-inline">

                <input type="text" name="lectureTime" id="lectureTime" autocomplete="off" maxlength="50" class="layui-input"   placeholder="yyyy-MM-dd HH:mm:ss">
            </div>
        </div>
    </div>
</div>

<div class="layui-row">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-inline">
                <input type="text" name="contactName" id="contactName" autocomplete="off" maxlength="50" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-inline">
                <input type="text" name="contactPhone" id="contactPhone" autocomplete="off" maxlength="50" class="layui-input" lay-verify="phone">
            </div>
        </div>
    </div>
</div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">讲座地点</label>
                <div class="layui-input-inline" style="width: 600px">
                    <input type="text" name="locationName" id="locationName" autocomplete="off" maxlength="80" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>

<!--<div class="layui-row">-->
    <!--<div class="layui-form-item">-->
        <!--<div class="layui-inline">-->
            <!--<label class="layui-form-label">注意事项</label>-->
            <!--<div class="layui-input-block" style="width:595px;">-->
                <!--<textarea name="lectureRemark"  id="lectureRemark" placeholder="请输入" class="layui-textarea" lay-verify="required" style="height: 120px"></textarea>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
<!--</div>-->

<div class="layui-row">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">讲座内容</label>
            <div class="layui-input-block" style="width:600px;z-index: 888">
                <div id="wxin-contentDesc" ></div>
                <input type="hidden" name="lectureContent" id="lectureContent"/>
            </div>
        </div>
    </div>
</div>
    <div class="layui-row">
        <div class="layui-form-item">
            <layui:image id="mainImg" tagName="讲座主图" tips="图片说明"/>
        </div>
    </div>
   <!-- <layui:image id="lectureImgs" tagName="讲座图片集合" tips="讲座图片集合"/>-->
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-upload">
                <label class="layui-form-label" style="width: 120px">讲座图片集合</label>
                <button type="button" class="layui-btn" id="test2">多图片上传</button>
                <!-- <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">-->

                <!-- <div class="layui-upload-list" id="demo2"></div>-->
                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;width: 650px;">
                    <div class="layui-upload-list uploader-list" style="overflow: auto;" id="uploader-list">

                    </div>
                </blockquote>
                <input type="hidden" name="lectureImgs" id="lectureImgs">
            </div>
        </div>
    </div>
    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
    $(document).on("mouseenter mouseleave", ".file-iteme", function(event){
        if(event.type === "mouseenter"){
            //鼠标悬浮
            $(this).children(".info").fadeIn("fast");
            $(this).children(".handle").fadeIn("fast");
        }else if(event.type === "mouseleave") {
            //鼠标离开
            $(this).children(".info").hide();
            $(this).children(".handle").hide();
        }
    });
    // 删除图片
    $(document).on("click", ".file-iteme .handle", function(event){
        $(this).parent().remove();
        var lectureImgs ="";
        $("#uploader-list img").each(function(){
              var img = $(this).attr("src");
              if(img!=null&&img!=""){
                    lectureImgs += img+"@";
                }
        });
        $("#lectureImgs").val(lectureImgs.substr(0,lectureImgs.length-1));
    });

    Common.initImage();




layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','orgLectureApi','upload'], function(exports) {
    var form = layui.form;
    var orgLectureApi = layui.orgLectureApi;
    var index = layui.index;
    var isNew = true;
    var upload = layui.upload;
    var laydate = layui.laydate;

    //常规用法
    laydate.render({
        elem: '#lectureTime',
        type: 'datetime',
        format: 'yyyy-MM-dd HH:mm:ss'
    });

    <!--# if(!(isEmpty(orgLectureJson))){  -->
        isNew = false;
        var imgs = "${orgLecture.lectureImgs}";
        if(imgs!=null&&imgs!=""&&imgs!=","){
            var arr = imgs.split("@");
            for ( var i = 0; i <arr.length; i++){
                $('#uploader-list').append(
                    '<div id="" class="file-iteme">' +
                    '<div class="handle"><span class="layui-icon layui-icon-delete"></span></div>' +
                    '<img style="width: 100px;height: 100px;" src='+ arr[i] +'>' +
                    '</div>'
                );
            }
        }
    <!--# } -->
    //多图回显

    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);

            //多图片上传
            upload.render({
                elem: '#test2'
                ,url: '${ctxPath}/orgLecture/orgLecture/upload.json'
                ,multiple: true
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    // obj.preview(function(index, file, result){
                    //
                    //     $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                    //
                    // });
                }
                ,done: function(res){
                    //上传完毕
                    if(res.state=='SUCCESS'){

                        $('#uploader-list').append(
                            '<div id="" class="file-iteme">' +
                            '<div class="handle"><span class="layui-icon layui-icon-delete"></span></div>' +
                            '<img style="width: 100px;height: 100px;" src='+ res.url +'>' +
                            '</div>'
                        );

                        var lectureImgs = $("#lectureImgs").val();
                        if(lectureImgs=="@"){
                            document.getElementById("lectureImgs").value="";
                            lectureImgs = $("#lectureImgs").val();
                        }

                        if(!lectureImgs){
                            lectureImgs += res.url;
                        }else{
                            lectureImgs += "@"+res.url;
                        }
                        $("#lectureImgs").val(lectureImgs);
                    }
                }
            });
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                document.getElementById("lectureContent").value=UE.getEditor('wxin-contentDesc').getContent();
                form.on('submit(form)', function(){
                    orgLectureApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(orgLectureJson))){  -->
    var formJson = ${orgLectureJson};
    form.val("editform",formJson);
    $(".image-preview").each(function() {
        $(this).attr("src",formJson[$(this).attr("id")]);
    });
    <!--# } -->
});
</script>

<script type="text/javascript"  src="${ctxPath}/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript"  src="${ctxPath}/plugins/ueditor/ueditor.all.js"></script>
<script type="text/javascript"  src="${ctxPath}/plugins/ueditor/xiumi-ue-dialog-v5.js"></script>

<script type="application/javascript">
    let ueditor_config = {
        // toolbars: [["undo", "redo", "|", "fontsize", "forecolor", "bold", "italic", "underline", "|", "justifyleft", "justifycenter", "justifyright", "justifyjustify", "lineheight", "|", "directionalityltr", "directionalityrtl", "indent", "|", "simpleupload", "|",  "spechars", "source", "|", "searchreplace", "|", "fullscreen","mobile"]],
        serverUrl: "${ctxPath}/orgLecture/orgLecture/config",
        autoHeightEnabled: false,
        elementPathEnabled : true,　　//是否启用元素路径，默认是true显示
        wordCount:false,          //是否开启字数统计
        initialFrameHeight:400,
        initialFrameWidth:850
    };
    var ue = UE.getEditor('wxin-contentDesc',ueditor_config);
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function(action) {
        if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadvideo') {
            console.log("upload");
            return '${ctxPath}/orgLecture/orgLecture/upload.json';
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }
    // 编辑
    setTimeout(function () {
        var bjcontentDesc=  document.getElementById("lectureContent").value;
        UE.getEditor('wxin-contentDesc').setContent(bjcontentDesc);
    },1000);


</script>